<?php

/**
 * Class represented product_axis table
 */
class product_axisTable {

	/**
	 * get the axis values from the product Id
	 * @author DRAMSY
	 * @param type $the_i_productId 
	 */
	public static function a_getAxisValuesByProductId($the_i_productId) {
		$o_connection = dbconnection::getInstance();
		$sz_sql = "SELECT id_axis,value FROM product_axis ";
		$sz_sql .= "JOIN axis ON axis.id = product_axis.id_axis ";
		$sz_sql .= "WHERE id_product=$the_i_productId ";

		$a_res = $o_connection->doQueryObject($sz_sql, "product");

		if ($a_res === false)
			return false;

		return $a_res;
	}
	
	/**
	 * Check if the selected product is already axed
	 * @param type $the_i_productId
	 */
	public static function isAxed($the_i_productId) {
		$o_connection = dbconnection::getInstance();
		$sz_sql = "SELECT * FROM product_axis ";
		$sz_sql .= "WHERE id_product=$the_i_productId ";
		
		$a_res = $o_connection->doQueryObject($sz_sql);
		return count($a_res) > 0;
	}
	
	/**
	 * Delete the informations about the product (all the axis)
	 * @param type $the_i_productId
	 */
	public static function deleteProductInformations($the_i_productId) {
		$o_connection = dbconnection::getInstance();
		$sz_sql = "DELETE FROM product_axis ";
		$sz_sql .= "WHERE id_product=$the_i_productId ";
		
		$a_res = $o_connection->doQueryObject($sz_sql);
		
		return true;
	}

}
